<?php

class m {
	public $now_user;
	public $now_nickname;
	function doAction($action,$posti){
		global $db;
		switch ($action) {
			case 'log':
				$db->ExeQuerySql("select * from `cu_manage` where username='$posti[usn]' and password='$posti[psw]'");
				if($db->FetchRow())
				{
					$root = $db->Get("root");
					if ($root>=1){
						$this->now_nickname = $db->Get("nickname");
						$this->gointo($posti['usn']);
					}else{
						echo "<script>alert('对不起，你還沒有資格進入!');</script>";
					}
				}else{
					echo "<script>alert('对不起，用戶名或密碼錯!');</script>";
				}
				break;
				}
		}
	function gointo($username=""){//通過驗證後調用這個命令
		global $JF;
		global $db;
		$datep =date("Y-m-d");
		$db->ExeQuerySql("select * from `cu_manage` where username='$username'");
		if ($db->Get("lastlogin")!=$datep){
			$nowjf = $db->Get("jifen")+$JF->getyjjf();
			$db->ExeSql("update `cu_manage` set lastlogin='$datep',jifen='$nowjf' where username='$username'");
		}
		$_SESSION['uid'] = $username;
		$this->now_user = $username;
	}
	function doAcav($action,$value){
		switch ($action){
			case 'logout':
				unset($_SESSION['uid']);
			break;
		}
	}
	function is_selog(){
		if(!empty($_SESSION['uid'])){
			$is_user = true;
		}else{
			$is_user = false;
		}
		return $is_user;
	}
	function getlogtab(){
		$page = '<div id="adminlogba"><div id="adminlog">
		<form id="jfdl" name="jfdl" method="post" action="index.php?action=log">
		<table id="adminlogtab" border="1" cellspacing="0"><tr height="20"><td>賬戶:<input type="text" name="usn" id="an"/></td><td rowspan="2"><input id="submitlog" name="adminlog-submit" value="登錄 " type="submit" /></td></tr><tr><td>密碼：<input type="password" name="psw" id="ap"/></td></tr></table>			</form>
		</div>
		</div>';
		return $page;
	}
	
}
?>